<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>Vue入门指南——响应式基础</title>
        <link rel="stylesheet" href="common.css">
        <script type="importmap">
            {
                "imports": {
                    "vue": "https://lib.baomitu.com/vue/latest/vue.esm-browser.js"
                }
            }
        </script>
    </head>
    <body>
        <div id="app">
            <section>
                <p>
                    <button v-on:click="increment">{{count}}</button>
                    <button v-on:click="testThis">不要使用箭头函数</button>
                </p>
            </section>
        </div>
        <script type="module">
            import { createApp } from 'vue';
            createApp({
                data() {
                    return {
                        count: 0,
                    };
                },
                methods: {
                    increment() {
                        console.log(this);
                        this.count++;
                    },
                    testThis() {
                        console.log(this);
                    }
                },
                mounted() {
                    console.log(`${this.$data.count}`);
                    this.count = 2;
                }
            }).mount('#app');
        </script>
    </body>
</html>
